package com.huli.controller;

import com.huli.pojo.NursingProject;
import com.huli.pojo.Patient;
import com.huli.service.OrderInfoService1;
import com.huli.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/orderInfoPatient1")
public class OrderInfo {
    @Autowired
    private OrderInfoService1 orderInfoService1;

    //查询订单未完成状态的列表1
    @RequestMapping("getOrderInfoPatientListNotOk1")
    public Result getOrderInfoPatientListNotOk1() {
        try {
            List<com.huli.domain.OrderInfo> list = orderInfoService1.getOrderInfoPatientListNotOk1();
            return Result.success(list);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("查询失败");
        }
    }

    //查询订单服务中的列表
    @RequestMapping("getOrderInfoPatientListService1")
    public Result getOrderInfoPatientListService1() {
        try {
            List<com.huli.domain.OrderInfo> list = orderInfoService1.getOrderInfoPatientListService1();
            return Result.success(list);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("查询失败");
        }
    }

    //查询订单待服务的列表
    @RequestMapping("getOrderInfoPatientListWaitService1")
    public Result getOrderInfoPatientListWaitService1() {
        try {
            List<com.huli.domain.OrderInfo> list = orderInfoService1.getOrderInfoPatientListWaitService1();
            return Result.success(list);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("查询失败");
        }
    }


    //查询订单已取消的列表
    @RequestMapping("getOrderInfoPatientListCancel1")
    public Result getOrderInfoPatientListCancel1() {
        try {
            List<com.huli.domain.OrderInfo> list = orderInfoService1.getOrderInfoPatientListCancel1();
            return Result.success(list);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("查询失败");
        }
    }

    //查询订单已完成状态的列表
    @RequestMapping("getOrderInfoPatientListOk1")
    public Result getOrderInfoPatientListOk1() {
        try {
            List<com.huli.domain.OrderInfo> list = orderInfoService1.getOrderInfoPatientListOk1();
            return Result.success(list);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("查询失败");
        }
    }

    //查询订单待排单列表
    @RequestMapping("getOrderInfoPatientListWait1")
    public Result getOrderInfoPatientListWait1() {
        try {
            List<com.huli.domain.OrderInfo> list = orderInfoService1.getOrderInfoPatientListWait1();
            return Result.success(list);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("查询失败");
        }
    }

    //根据ID进行查询护士
    @RequestMapping("getNurseID")
    public Result getNurseID(Integer id) {
        try {
            String list = orderInfoService1.getNurseID(id);
            return Result.success(list);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("查询失败");
        }
    }

    //根据传过来的ID进行地址查询
    @RequestMapping("getAddressID")
    public Result getAddressID(Integer id) {
        try {
            String list = orderInfoService1.getAddressID(id);
            return Result.success(list);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("查询失败");
        }
    }

    //进行派单
    @RequestMapping("updateOrderStatus")
    public Result updateOrderStatus(Integer id, Integer status) {
        try {
            Integer aaa = orderInfoService1.updateOrderStatus(id, status);
            return Result.success(aaa);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("派单失败");
        }
    }

    //根据传过来的ID进行查询项目
    @RequestMapping("getProjectID")
    public Result getProjectID(Integer id) {
        try {
            NursingProject list = orderInfoService1.getProjectID(id);
            return Result.success(list);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("查询失败");
        }
    }

    //根据传过来的ID进行查询患者信息
    @RequestMapping("getPtientID")
    public Result getPtientID(Integer id) {
        try {
            Patient list = orderInfoService1.getPtientID(id);
            return Result.success(list);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("查询失败");
        }
    }


    //将获取到的验证码进行比较是否一致
    @RequestMapping("getVerificationCode")
    public Result getVerificationCode(Integer id, String appointmentCode) {
        try {
            int aaa = orderInfoService1.getVerificationCode(id, appointmentCode);
            return Result.success(aaa);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("查询失败");
        }
    }

    //根据传过来的ID进行修改状态
    @RequestMapping("updateOrderStatus1")
    public Result updateOrderStatus1(Integer id) {
        try {
            Integer aaa = orderInfoService1.updateOrderStatus1(id);
            return Result.success(aaa);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("完成定单失败");
        }
    }

    //查询所有订单
    @RequestMapping("getOrderInfoList")
    public Result getOrderInfoList() {
        try {
            List<com.huli.domain.OrderInfo> list = orderInfoService1.getOrderInfoList();
            return Result.success(list);
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("查询失败");
        }
    }
    //查询未读的信息发送
    @RequestMapping("getOrderInfoPatientListNotOk")
    public List<com.huli.domain.OrderInfo> getOrderInfoPatientListNotOk(String messageStayus){
        return orderInfoService1.getOrderInfoPatientListNotOk(messageStayus);
    }


    //查询已读的信息发送
    @RequestMapping("getOrderInfoPatientListToOk")
    public List<com.huli.domain.OrderInfo> getOrderInfoPatientListToOk(String messageStayus){
        return orderInfoService1.getOrderInfoPatientListToOk(messageStayus);
    }

    //累计接单
    @RequestMapping("getOrderInfoPatientListToOkCount")
    public Integer getOrderInfoPatientListToOkCount(){
        return orderInfoService1.getOrderInfoPatientListToOkCount();
    }


}
